const connection = require("../app/database");

class ArticleCategoryService {
  async create(content) {
    const statement = `INSERT INTO asck_article_category (content) VALUES (?);`;
    const [result] = await connection.execute(statement, [
      content
    ]);
    return result;
  }
  async reply(momentId, content, userId, commentId) {
    const statement = `INSERT INTO comment (content,moment_id,user_id,comment_id) VALUES (?,?,?,?);`;
    const [result] = await connection.execute(statement, [
      content,
      momentId,
      userId,
      commentId,
    ]);
    return result;
  }

  async update(content,id) {
    const statement = `UPDATE asck_article_category SET content =? WHERE id=?;`;
    const [result] = await connection.execute(statement, [content,id]);
    return result;
  }

  async remove(commentId) {
    const statement = `DELETE  FROM asck_article_category WHERE id=?;`;
    const [result] = await connection.execute(statement, [commentId]);
    return result;
  }

  async list() {
    const statement = `SELECT * FROM asck_article_category`;
    const [result] = await connection.execute(statement);
    return result;
  }
}

module.exports = new ArticleCategoryService();
